package org.dlsu.mt.parser.generation;

public class Phrase
{
	private PhraseList contents;
	private int numElements;
	
	public Phrase()
	{
		contents = new PhraseList();
		numElements=0;
	}
	
	public boolean addElement(ListElement c)
	{
		if(contents.addElement(c))
		{
			numElements++;
			return true;
		}
		else
			return false;
	}
	
	public ListElement getElement(int index)
	{
		if(index<=numElements)
			return contents.getElement(index);
		else
			return null;
	}
	
	public boolean removeElement(int i)
	{
		if(i<=numElements)
		{
			contents.removeElement(i);
			numElements--;
			return true;
		}
		return false;
	}
	
	public int getNumElements()
	{
		return numElements;
	}
	
	public String toString()
	{
		StringBuffer temp = new StringBuffer();
		temp.append("Phrase( LFG \n");
		
		if(contents != null)
			temp.append(contents.toString());
		
		temp.append(")\n");
		
		return temp.toString();
	}
}